package cn.tedu.hotel_management_system.base.aspect;

import cn.tedu.hotel_management_system.base.exception.HotelManagementException;
import cn.tedu.hotel_management_system.base.json_result.ResultDataDto;
import cn.tedu.hotel_management_system.base.json_result.ResultDto;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author dkk
 * @date 2022/9/11
 * @desc 统一异常处理
 */
@RestControllerAdvice
public class HotelExceptionHandler {

    @ExceptionHandler(HotelManagementException.class)
    public ResultDto<Void> handleTemplateException(HotelManagementException e){
        ResultDto<Void> resultDto = new ResultDto<>();
        String errorMes = e.getMessage();
        resultDto.setMes(errorMes);
        resultDto.setIsSuccess(false);
        return resultDto;
    }

}
